package com.leyou.auth.feign;

import com.leyou.auth.task.IntervalTokenHolder;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author 虎哥
 */
@Component
public class PrivilegeTokenInterceptor implements RequestInterceptor {

    @Autowired
    private IntervalTokenHolder tokenHolder;

    @Override
    public void apply(RequestTemplate template) {
        // 添加token到请求头
        template.header("heima95", tokenHolder.getToken());
    }
}
